1 /*
2 * Angkor Web Framework
3 *
4 * Distributable under LGPL license.
5 * See terms of license at gnu.org.
6 */
7
8 package com.tirsen.angkor.table;
9
10 import com.tirsen.angkor.View;
11 import com.tirsen.angkor.event.ChangeListener;
12 import com.tirsen.angkor.event.ChangeSource;
13 import com.tirsen.angkor.event.ChangeSourceHelper;
14 import com.tirsen.angkor.widget.ValueModel;
15
16 import java.io.Serializable;
17
18 /***
19 * @author $Author: tirsen $
20 * @version $Revision: 1.4 $
21 * <BR>
22 * $Id: TableColumn.java,v 1.4 2002/10/09 21:37:37 tirsen Exp $
23 */
24 public class TableColumn implements Serializable, ChangeSource
25 {
26 private int modelColumn;
27 private TableModel model;
28 private TableCellViewFactory viewFactory;
29 private boolean visible = true;
30 private ChangeSourceHelper changeSourceHelper = new ChangeSourceHelper(this);
31
32 public TableColumn(TableCellViewFactory viewFactory)
33 {
34 this.viewFactory = viewFactory;
35 }
36
37 public TableColumn(TableModel model, int index)
38 {
39 this.modelColumn = index;
40 this.model = model;
41 }
42
43 public void setViewFactory(TableCellViewFactory viewFactory)
44 {
45 this.viewFactory = viewFactory;
46 changeSourceHelper.signalChangeEvent();
47 }
48
49 private TableCellViewFactory getViewFactory()
50 {
51 return viewFactory;
52 }
53
54 public View getCellView(Table view, int row, int column)
55 {
56 System.out.println("creating row = " + row);
57 ValueModel value = getCellModel(row);
58 return getViewFactory().getTableCellView(view, value, row, column);
59 }
60
61 public ValueModel getCellModel(int row)
62 {
63 ValueModel value;
64 if (model != null)
65 {
66 value = model.getValueAt(row, modelColumn);
67 }
68 else
69 {
70 value = null;
71 }
72 return value;
73 }
74
75 public String getColumnName()
76 {
77 if (model != null)
78 return model.getColumnName(modelColumn);
79 else
80 return null;
81 }
82
83 public boolean isVisible()
84 {
85 return visible;
86 }
87
88 public void setVisible(boolean visible)
89 {
90 this.visible = visible;
91 changeSourceHelper.signalChangeEvent();
92 }
93
94 public void addChangeListener(ChangeListener listener)
95 {
96 changeSourceHelper.addChangeListener(listener);
97 }
98
99 public void removeChangeListener(ChangeListener listener)
100 {
101 changeSourceHelper.removeChangeListener(listener);
102 }
103 }
This page was automatically generated by Maven